package com.etc.patient.controller;

import com.etc.common.utils.Result;
import com.etc.common.entity.BasicPatient;
import com.etc.patient.service.BasicPatientService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/patient")
public class BasicPatientController {

    @Resource
    private BasicPatientService basicPatientService;

    /**
     * 查询医生Id下的正在治疗的病人信息
     *
     * @return
     */
    @GetMapping("/queryByDocId")
    public Result queryDocId(@RequestParam("pageNum")Integer pageNum, @RequestParam("pageSize")Integer pageSize, @RequestParam("docId")String docId) {
        return basicPatientService.queryDocId(pageNum, pageSize, docId);
    }


    /**
     * 新增病人信息
     *
     * @return
     */
    @PostMapping("/insert")
    public Result insert(@RequestBody BasicPatient basicPatient, @RequestParam("docId") String docId) {
        return basicPatientService.insert(basicPatient, docId);

    }

    /**
     * 修改病人信息
     *
     * @return
     */
    @PostMapping("/update")
    public Result update(@RequestBody BasicPatient basicPatient, @RequestParam("operatorId") String operatorId) {
        return basicPatientService.updateById(basicPatient, operatorId);
    }

    /**
     * 批量结束病人治疗
     *
     * @param ids
     * @param operatorId
     * @return
     */
    @PostMapping ("/endPatient")
    public Result endPatient(@RequestParam("ids") String[] ids, @RequestParam("operatorId") String operatorId) {
        return basicPatientService.endPatient(ids, operatorId);
    }
}
